package com.jinyuan.options.setting;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

import com.jinyuan.R;
import com.jinyuan.options.OptionsFragment;
import com.jinyuan.options.setting.adapter.SettingAdapter;
import com.jinyuan.options.update.UpdateActivity;
import com.jinyuan.view.dialog.NetAddressDialog;

/**
 * 设置
 *
 * @author azuryleaves
 * @since 2014-1-8 下午2:11:11
 * @version 1.0
 *
 */
public class SettingFragment extends OptionsFragment {

	private ListView listView;
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		setTitle(R.string.setting);
		listView = getGeneralListView();
		String[] data = getResources().getStringArray(R.array.setting_list);
		SettingAdapter adapter = new SettingAdapter(getActivity(), data);
		listView.setAdapter(adapter);
		listView.setOnItemClickListener(itemClickListener);
		return listView;
	}
	
	private OnItemClickListener itemClickListener = new OnItemClickListener() {

		@Override
		public void onItemClick(AdapterView<?> adapterView, View view, int position,
				long id) {
			switch (position) {
			case 0:
				NetAddressDialog dialog = new NetAddressDialog(getActivity());
				dialog.show();
				break;
			case 1:
				Intent intent = new Intent(SettingFragment.this.getActivity(), UpdateActivity.class);
				startActivity(intent);
				break;
			default:
				break;
			}
		}
	};
	
}
